function recuperarSenha() {
    var email = $("#recSenhaEmail").val();
    if (email === '') {
        swal('Ooops...', 'O campo email deverá ser preenchido.', 'error');
        return false;
    }
    var filtro = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;
    if (filtro.test(email)) {
        var email = encodeURIComponent(email);
        $('#fmG').html('Carregando...');
        $('#sendMail').hide();
        $.ajax('./usuario/recuperarsenha/?email=' + email).done(function (data) {
            var rtnSenha = eval('(' + data + ')');
            if (rtnSenha.sts) {
                $('#fmG').html('<p>&nbsp;</p>' + rtnSenha.msg + '<p>&nbsp;</p>');
            } else {
                swal('Ooops...', rtnSenha.msg, 'error');
                $("#rc_senha").trigger('click');
            }
        });
    } else {
        swal('Ooops...', 'Este endereço de email é inválido.', 'error');
        return false;
    }
}
$(document).ready(function () {
    if (localStorage.chkbx && localStorage.chkbx !== '') {
        $('#remember_me').attr('checked', 'checked');
        $('#login').val(localStorage.usrname);
    } else {
        $('#remember_me').removeAttr('checked');
    }

    $('#remember_me').click(function () {
        if ($('#remember_me').is(':checked')) {
            localStorage.usrname = $('#login').val();
            localStorage.chkbx = $('#remember_me').val();
        } else {
            localStorage.usrname = '';
            localStorage.chkbx = '';
        }
    });
    $("#login").focus().keyup(function () {
        if ($('#remember_me').is(':checked')) {
            localStorage.usrname = $('#login').val();
        }
    });
    $('#send').click(function () {
        var erros = 0;
        $(".form-control").each(function () {
            grupo = $(this).closest('.form-group');
            campo = $(this).attr('name');
            if ($(this).val().length === 0) {
                grupo.addClass('error');
                erros++;
            } else {
                grupo.removeClass('error');
            }
        });
        if (erros > 0) {
            return false;
        } else {

            $(this).closest('form').submit();
        }
    });
    $("#rc_senha").click(function () {
        $('.login-layer').fadeOut('slow', function () {
            $('.rc-senha-layer').html('<p>Carregando...</p>').fadeIn('slow', function () {
                $('.rc-senha-layer').load('./usuario/recuperarsenha', function () {
                    $('#sendMail').click(function () {
                        recuperarSenha();
                        return false;
                    });
                    $('#cancel').click(function () {
                        window.location.hash = '';
                        history.pushState('', document.title, window.location.pathname);
                        $('.rc-senha-layer').html('Carregando...').fadeOut('slow', function () {
                            $('.login-layer').fadeIn('slow');
                        });
                        return false;
                    });
                });
            });
        });
    });
    if (window.location.hash === '#recuperarSenha') {
        $("#rc_senha").trigger('click');
    }
    var mainslider;
    var sliding = false;
    var options = {
        slides: '.slide', // The name of a slide in the slidesContainer
        swipe: false, // Add possibility to Swipe > note that you have to include touchSwipe for this
        transition: "slide", // Accepts "slide" and "fade" for a slide or fade transition
        slideTracker: true, // Add a UL with list items to track the current slide
        slideTrackerID: 'slideposition', // The name of the UL that tracks the slides
        slideOnInterval: false, // Slide on interval
        interval: 3000, // Interval to slide on if slideOnInterval is enabled
        animateDuration: 1000, // Duration of an animation
        animationEasing: 'easeOutBack', // Accepts: linear ease in out in-out snap easeOutCubic easeInOutCubic easeInCirc easeOutCirc easeInOutCirc easeInExpo easeOutExpo easeInOutExpo easeInQuad easeOutQuad easeInOutQuad easeInQuart easeOutQuart easeInOutQuart easeInQuint easeOutQuint easeInOutQuint easeInSine easeOutSine easeInOutSine easeInBack easeOutBack easeInOutBack
        pauseOnHover: false, // Pause when user hovers the slide container
        magneticSwipe: true, // This will attach the slides to the mouse's position when swiping/dragging
        neverEnding: true // Enable this to create a 'neverending' effect.
    };

    $(".slider").simpleSlider(options);
    mainslider = $(".slider").data("simpleslider");
    /* yes, that's all! */

    $(".slider").on("beforeSliding", function (event) {
        var prevSlide = event.prevSlide;
        var newSlide = event.newSlide;
        $(".slider .slide[data-index='" + prevSlide + "'] .slidecontent").fadeOut();
        $(".slider .slide[data-index='" + newSlide + "'] .slidecontent").hide();

        sliding = true;
    });

    $(".slider").on("afterSliding", function (event) {
        var prevSlide = event.prevSlide;
        var newSlide = event.newSlide;
        $(".slider .slide[data-index='" + newSlide + "'] .slidecontent").fadeIn();
        sliding = false;
    });

    /**
     * Control the slider by scrolling
     */
    $(window).bind('mousewheel', function (event) {
        if (!sliding) {
            if (event.originalEvent.deltaY > 0) {
                mainslider.nextSlide();
            }
            else {
                mainslider.prevSlide();
            }
        }
    });

    $('.nxt-sld').on('click', function (event) {
        if (!sliding) {
            mainslider.nextSlide();
        }
    });

    $(".slide#first").backstretch("public_html/imagens/slider/bg1.jpg");
    $(".slide#sec").backstretch("public_html/imagens/slider/bg2.jpg");
    $(".slide#thirth").backstretch("public_html/imagens/slider/bg4.jpg");
    $(".slide#fourth").backstretch("public_html/imagens/slider/bg5.jpg");

    $('.slide .backstretch img').on('dragstart', function (event) {
        event.preventDefault();
    });

    $(".slidecontent").each(function () {
        $(this).css('margin-top', -$(this).height() / 2);
    });
});